package com.xbang.attendance.web.action.purchase.scope;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.companygps.scope;
import com.xbang.attendance.entity.department.Department;
import com.xbang.attendance.entity.userinfo.Userinfo;
import com.xbang.attendance.service.PurchaseOrderService;
import com.xbang.core.struts.support.SearchActionSupport;

public class scopeManager  extends SearchActionSupport{

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub
		
	}
	@Autowired
	private PurchaseOrderService purchaseOrderService;

	private List<scope> scopes;
	
	private scope scope;
	
	private Integer id;
	@Action("/purchase/scope/${id}/edit")
	public String detail() throws Exception {
		scope=new scope();
		if (id != null) {
			scopes=purchaseOrderService.getObjects(scope.class);
			scope = (scope) purchaseOrderService.getObject(scope.class, id);
		}
		return "detail";
	}
	
	@Action("/purchase/scope/add")
	public String add() throws Exception {
		scope=new scope();
		scopes=purchaseOrderService.getObjects(scope.class);
		return "detail";
	}
	@Action("/purchase/scope/save")
	public String save() throws Exception {
		if (null !=scope) {
			//int did=Integer.parseInt(user.getDepartment());
			//user.setDepartment(did+"");
			purchaseOrderService.save(scope);
			}
		
		return "r:/purchase/scope/list";
	}
	@Action("/purchase/scope/update")
	public String update() throws Exception {
		purchaseOrderService.update(scope);		
		return "r:/purchase/scope/list";
	}
	
	public PurchaseOrderService getPurchaseOrderService() {
		return purchaseOrderService;
	}

	public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
		this.purchaseOrderService = purchaseOrderService;
	}

	public List<scope> getScopes() {
		return scopes;
	}

	public void setScopes(List<scope> scopes) {
		this.scopes = scopes;
	}

	public scope getScope() {
		return scope;
	}

	public void setScope(scope scope) {
		this.scope = scope;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	
}
